package com.simon.resourcestatistics.controller;

import java.util.List;

import javax.annotation.Resource;

import com.simon.resourcestatistics.dao.IReadRoomDao;
import com.simon.resourcestatistics.model.ReadRoom;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

/**
 * ReadRoomController
 */
@RestController
@RequestMapping("/rearoom")
public class ReadRoomController {

    @Resource
    private IReadRoomDao readRoomDao;

    @ApiOperation(value="查询所有资源信息",notes="显示资源 信息")
    @GetMapping
    public List<ReadRoom> findAll(){
        return readRoomDao.findAll();
    }
    
    @ApiOperation(value="添加资源信息",notes="tj资源 信息")
    @PostMapping("/add")
    public ReadRoom add(@RequestBody ReadRoom r){
        return readRoomDao.save(r);
    }

    @ApiOperation(value="删除资源",notes = "delete")
    @ApiImplicitParam(name = "id",value = "主键",required = true,paramType = "path")
    @PostMapping("/del/{id}")
    public int del(@PathVariable int id){
        return readRoomDao.delById(id);
    }

    @ApiOperation(value = "修改资源",notes = "update")
    @PostMapping("/edit/{id}/{name}/{remark}")
    public int editReadRoom(@PathVariable Integer id,@PathVariable String name,@PathVariable String remark){
        return readRoomDao.editReadRoom(id, name, remark);
    }
}